package com.neegix.log.loginLog.infrastructure.repository.impl;

import com.neegix.application.query.NebulaSQL;
import com.neegix.base.PageVO;
import com.neegix.log.loginLog.application.assembler.LoginLogAssembler;
import com.neegix.log.loginLog.application.repository.LoginLogQueryRepository;
import com.neegix.log.loginLog.infrastructure.repository.dataobject.LoginLogDO;
import com.neegix.log.loginLog.infrastructure.repository.mapper.LoginLogMapper;
import com.neegix.log.loginLog.interfaces.vo.LoginLogVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

 /**
  * This file is auto-generated by nebula-framework-generator.
  * The auto-generation plugin was developed using IntelliJ IDEA Community Edition.
  * Thanks to JetBrains for their outstanding contributions to the developer community.
  * <p>
  * The code generated by this tool is owned by the user of the tool.
  * The tool itself is copyrighted by <a href="https://www.neegix.com">https://www.neegix.com</a>.
  *
  * @author <a href="https://www.neegix.com">https://www.neegix.com</a>
  * @version 1.0.0
  * @since 2024-12-19 15:39:21
  */

@Repository
public class LoginLogQueryRepositoryImpl implements LoginLogQueryRepository {

    @Autowired
    private LoginLogMapper loginLogMapper;

    @Override
    public PageVO<LoginLogVO> findPage(Integer currentPage, Integer pageSize, NebulaSQL nebulaSQL) {
        nebulaSQL.setPager(currentPage, pageSize);
        List<LoginLogDO> result = loginLogMapper.selectList(nebulaSQL);
        Long total = loginLogMapper.selectCount(nebulaSQL);
        PageVO<LoginLogVO> page = new PageVO<>(currentPage, pageSize);
        page.setTotal(total);
        page.setResult(LoginLogAssembler.INSTANCE.covertVO(result));
        return page;
    }
}
